//
//  BaseInformationTableViewCell.m
//  BeanTrip
//
//  Created by dlios on 15-7-11.
//  Copyright (c) 2015年 PandaGroup. All rights reserved.
//

#import "BaseInformationTableViewCell.h"
#define WIDTH self.contentView.frame.size.width/375
#define HEIGHT self.contentView.frame.size.height/667
@implementation BaseInformationTableViewCell
- (void)dealloc
{
    [_baseLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.baseLabel = [[UILabel alloc] init];
        /**
         * 给label设置字体大小,前后保持一致
         */
        self.baseLabel.font = [UIFont systemFontOfSize:14];
        self.baseLabel.numberOfLines = 0;
        [self.contentView addSubview:self.baseLabel];
        [self.baseLabel release];
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14],NSFontAttributeName, nil];
    /**
     *  根据文本来计算高度,首先限制一个文本的最大范围(375,0)苹果6
     *  第二个属性作用:指定一个属性来定义对应文本和字体所占用的高度.
     */
    
    CGRect rect=[self.baseLabel.text boundingRectWithSize:CGSizeMake(375*WIDTH, 0) options: NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.baseLabel.frame = CGRectMake(0, 0, 375*WIDTH, rect.size.height);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
